package cn.tansanqinger.dao.sql.chatroom;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.tansanqinger.dao.sql.IUnauthorizedSqlDao;
import cn.tansanqinger.pojo.Unauthorized;

@Repository
public class UnauthorizedSqlDaoImpl {

	@Autowired
	private IUnauthorizedSqlDao dao;
	
	/**
	 * 查询用户被添加的所有信息
	 * @param id
	 * @return
	 */
	public List<Unauthorized> selectUnauthorizeds(int id){
		QueryWrapper<Unauthorized> queryWrapper = new QueryWrapper<Unauthorized>();
		queryWrapper.lambda().eq(Unauthorized::getBeuid, id).eq(Unauthorized::getIsdispose, 0).or();
		queryWrapper.lambda().eq(Unauthorized::getBeuid, id).eq(Unauthorized::getIspass, 1);
		return dao.selectList(queryWrapper);
	}
	
	/**
	 * 查询用户新信息条数
	 * @param id
	 * @return
	 */
	public int selectNumber(int id) {
		QueryWrapper<Unauthorized> queryWrapper = new QueryWrapper<Unauthorized>();
		queryWrapper.lambda().eq(Unauthorized::getBeuid, id).eq(Unauthorized::getIsselect, 0);
		return dao.selectCount(queryWrapper);
	}
	
	/**
	 * 添加信息
	 * @param course
	 * @return
	 */
	public int add(Unauthorized object) {
		return dao.insert(object);
	}
	
	/**
	 * 查询信息
	 * @param cid
	 * @return
	 */
	public Unauthorized selectOnt(int id) {
		return dao.selectById(id);
	}
	
	/**
	 * 删除信息
	 * @param cid
	 * @return
	 */
	public int deleteOne(int id) {
		return dao.deleteById(id);
	}
	
	/**
	 * 修改信息
	 * @param user
	 * @return
	 */
	public int modification(Unauthorized object) {
		return dao.updateById(object);
	}
}
